package com.ruoyi.quality.controller.web;

import com.ruoyi.common.core.controller.BaseController;

import com.ruoyi.safe.domain.BizSafeAttach;
import com.ruoyi.safe.domain.BizSafeDocAttach;
import com.ruoyi.safe.domain.vo.BizSafeDocAttachVO;
import com.ruoyi.safe.service.IBizSafeAttachService;
import com.ruoyi.safe.service.IBizSafeDocAttachService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;


/**
 * 文件Controller
 * 
 * @author mahl2
 * @date 2024-02-05
 */
@RestController
@RequestMapping("/quality/fileDownload")
public class FileDownloadController extends BaseController
{
    @Autowired
    IBizSafeDocAttachService fileDocAttachService;
    @Autowired
    IBizSafeAttachService fileAttachService;

    /**
     * 查询文件列表
     */
    @PreAuthorize("@ss.hasPermi('quality:fileDownload:list')")
    @GetMapping("/list")
    public List list(String ids)
    {
        BizSafeDocAttach fileDocAttach = new BizSafeDocAttach();
        String[] strlist = ids.split(",");
        List<Long> listIds = new ArrayList<Long>(strlist.length);
        for (int i = 0; i < strlist.length; ++i)
        {
            listIds.add( Long.parseLong(strlist[i]));
        }
        fileDocAttach.setIds(listIds);
        /** 资料文档附件列表 */
        List<BizSafeDocAttachVO> fileDocAttachList = fileDocAttachService.selectFileDocAttachListIds(fileDocAttach);
        return fileDocAttachList;
    }

    /**
     * 查询图片列表
     */
    @PreAuthorize("@ss.hasPermi('quality:fileDownload:list')")
    @GetMapping("/listPic")
    public List listPic(String ids)
    {
        BizSafeAttach bizSafeAttach = new BizSafeAttach();
        String[] strlist = ids.split(",");
        List<Long> listIds = new ArrayList<Long>(strlist.length);
        for (int i = 0; i < strlist.length; ++i)
        {
            listIds.add( Long.parseLong(strlist[i]));
        }
        bizSafeAttach.setIds(listIds);
        /** 资料文档附件列表 */
        List<BizSafeAttach> fileDocAttachList = fileAttachService.selectBizSafeAttachListIds(bizSafeAttach);
        return fileDocAttachList;
    }

}
